using Digitalmes.Domain.Entities.Mes.Equipments;

namespace Digitalmes.Application.Mes.Equipments.Inspections.Commands;

/// <summary>
/// 设备点检计划删除命令
/// </summary>
/// <param name="PlanId">点检计划 Id</param>
public sealed record DeleteInspectionPlanCommand(long PlanId) : IRequest<IResult<bool>>;

internal sealed class DeleteInspectionPlanCommandHandler(IRepository<EquipInspectionPlan> repo) : IRequestHandler<DeleteInspectionPlanCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteInspectionPlanCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.PlanId, cancellationToken);
        return Result.From(ok);
    }
}
